home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / exampleCode / opengl / GLUT / test / cursor_test.c < prev    next >
C/C++ Source or Header  |  1996-11-11  |  2KB  |  112 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees 
  5.    and is provided without guarantee or warrantee expressed or 
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <GL/glut.h>
  11.  
  12. int cursor[] =
  13. {
  14.   GLUT_CURSOR_INHERIT,
  15.   GLUT_CURSOR_NONE,
  16.   GLUT_CURSOR_FULL_CROSSHAIR,
  17.   GLUT_CURSOR_RIGHT_ARROW,
  18.   GLUT_CURSOR_LEFT_ARROW,
  19.   GLUT_CURSOR_INFO,
  20.   GLUT_CURSOR_DESTROY,
  21.   GLUT_CURSOR_HELP,
  22.   GLUT_CURSOR_CYCLE,
  23.   GLUT_CURSOR_SPRAY,
  24.   GLUT_CURSOR_WAIT,
  25.   GLUT_CURSOR_TEXT,
  26.   GLUT_CURSOR_CROSSHAIR,
  27.   GLUT_CURSOR_UP_DOWN,
  28.   GLUT_CURSOR_LEFT_RIGHT,
  29.   GLUT_CURSOR_TOP_SIDE,
  30.   GLUT_CURSOR_BOTTOM_SIDE,
  31.   GLUT_CURSOR_LEFT_SIDE,
  32.   GLUT_CURSOR_RIGHT_SIDE,
  33.   GLUT_CURSOR_TOP_LEFT_CORNER,
  34.   GLUT_CURSOR_TOP_RIGHT_CORNER,
  35.   GLUT_CURSOR_BOTTOM_RIGHT_CORNER,
  36.   GLUT_CURSOR_BOTTOM_LEFT_CORNER,
  37.   0,
  38. };
  39.  
  40. char *name[] =
  41. {
  42.   "INHERIT",
  43.   "NONE",
  44.   "FULL CROSSHAIR",
  45.   "RIGHT ARROW",
  46.   "LEFT ARROW",
  47.   "INFO",
  48.   "DESTROY",
  49.   "HELP",
  50.   "CYCLE",
  51.   "SPRAY",
  52.   "WAIT",
  53.   "TEXT",
  54.   "CROSSHAIR",
  55.   "UP DOWN",
  56.   "LEFT RIGHT",
  57.   "TOP SIDE",
  58.   "BOTTOM SIDE",
  59.   "LEFT SIDE",
  60.   "RIGHT SIDE",
  61.   "TOP LEFT CORNER",
  62.   "TOP RIGHT CORNER",
  63.   "BOTTOM RIGHT CORNER",
  64.   "BOTTOM LEFT CORNER",
  65.   NULL,
  66. };
  67.  
  68. void
  69. menu(int value)
  70. {
  71.   int cursor;
  72.  
  73.   glutSetCursor(value);
  74.   cursor = glutGet(GLUT_WINDOW_CURSOR);
  75.   if (cursor != value) {
  76.     printf("cursor_test: cursor not set right\n");
  77.     exit(1);
  78.   }
  79. }
  80.  
  81. void
  82. display(void)
  83. {
  84.   glClear(GL_COLOR_BUFFER_BIT);
  85. }
  86.  
  87. int
  88. main(int argc, char **argv)
  89. {
  90.   int win, i;
  91.  
  92.   glutInit(&argc, argv);
  93.   win = glutCreateWindow("cursor test");
  94.   glClearColor(0.49, 0.62, 0.75, 0.0);
  95.   glutDisplayFunc(display);
  96.   glutCreateMenu(menu);
  97.   for (i = 0; name[i] != NULL; i++) {
  98.     glutAddMenuEntry(name[i], cursor[i]);
  99.   }
  100.   glutAttachMenu(GLUT_RIGHT_BUTTON);
  101.   glutCreateSubWindow(win, 10, 10, 90, 90);
  102.   glutAttachMenu(GLUT_RIGHT_BUTTON);
  103.   glClearColor(0.3, 0.82, 0.55, 0.0);
  104.   glutDisplayFunc(display);
  105.   glutCreateSubWindow(win, 80, 80, 90, 90);
  106.   glutAttachMenu(GLUT_RIGHT_BUTTON);
  107.   glClearColor(0.9, 0.2, 0.2, 0.0);
  108.   glutDisplayFunc(display);
  109.   glutMainLoop();
  110.   return 0;             /* ANSI C requires main to return int. */
  111. }
  112.